package com.core.ui.controls;

public class ControlEdit
        extends UIControl {

	private String  caption;
	private String  formFieldName;
	private String  data;
	private boolean readonly = false;



	public boolean isReadonly () {

		return readonly;
	}



	public void setReadonly ( boolean readonly ) {

		this.readonly = readonly;
	}



	public String getCaption () {

		return caption;
	}



	public void setCaption ( String caption ) {

		this.caption = caption;
	}



	public String getFormFieldName () {

		return formFieldName;
	}



	public void setFormFieldName ( String formFieldName ) {

		this.formFieldName = formFieldName;
	}



	public String getData () {

		return data;
	}



	public void setData ( String data ) {

		this.data = data;
	}



	@Override
	public String toString () {

		String result = null;

		if ( readonly ) {
			result = String.format("<strong class=\"name\">%s</strong>%s", this.caption, this.data);

		} else {
			result = String.format(
			        "<strong class=\"name\">%s</strong><input type=\"text\" name=\"%s\" value=\"%s\" class=\"long-input\">",
			        this.caption,
			        this.formFieldName,
			        this.data);
		}

		return result;
	}
}
